#include<bits/stdc++.h>
using namespace std;
const int maxn=8005;
struct Node{
	int a,x,sortn;
}aa[maxn];
int n,q,a,x,v,vv;
bool cmd1(Node a,Node b){
	return a.x<b.x;
}
void sort1(){
	for (int i = 1; i <= n; i++){
		for (int j = i; j>=2; j--){
			if ( aa[j].a < aa[j-1].a ){
				Node a = aa[j-1];
				aa[j-1]=aa[j];
				aa[j]=a;
			}
		}
	}
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>aa[i].a;
		aa[i].x=i;
	}
	sort1();
	for(int i=1;i<=n;i++){
		aa[i].sortn=i;
	}
	sort(aa+1,aa+n+1,cmd1);
	for(int i=1;i<=q;i++){
		cin>>a>>x;
		if(a==1){
			cin>>v;
			vv=aa[x].a;
			aa[x].a=v;
			for(int i=1;i<=n;i++){
				if(i==x) continue;
				if(vv>aa[i].a){
					if(v<aa[i].a||(v==aa[i].a&&aa[x].x<aa[i].x)){
						aa[i].sortn+=1;
						aa[x].sortn-=1;
					}
				}
				if(vv==aa[i].a){
					if(aa[x].x<aa[i].x&&v>aa[i].a){
						aa[i].sortn-=1;
						aa[x].sortn+=1;
					}
					else if(aa[x].x>aa[i].x&&v<aa[i].a){
						aa[i].sortn+=1;
						aa[x].sortn-=1;
					}
				}
				if(vv<aa[i].a){
					if(v>aa[i].a||(v==aa[i].a&&aa[x].x>aa[i].x)){
						aa[i].sortn-=1;
						aa[x].sortn+=1;
					}
				}
			}
		}
		else{
			cout<<aa[x].sortn<<endl;
		}
	}
	return 0;
}
